package com.example.pluginmanager.config;

import com.example.pluginmanager.interceptor.ValidateJwtTokenInterceptor;
import com.example.pluginmanager.interceptor.ValidateUserPermissionsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private ValidateJwtTokenInterceptor validateJwtTokenInterceptor;

    @Autowired
    private ValidateUserPermissionsInterceptor validateUserPermissionsInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(validateJwtTokenInterceptor).addPathPatterns("/**").excludePathPatterns("/user/login","/user/generateValidateCode","/favicon.ico","/error").order(1);
        registry.addInterceptor(validateUserPermissionsInterceptor).addPathPatterns("/**").excludePathPatterns("/user/login","/user/generateValidateCode","/favicon.ico","/error").order(2);
    }
}
